<link rel="stylesheet" href="/images/datalist.css" type="text/css">
<script language="javascript" type="text/javascript" src="../my97datepicker/WdatePicker.js"></script>
<!-- <script language="javascript" type="text/javascript" src="../include/jquery-1.8.3.min.js"></script> -->

<style type="text/css">
  .col-md-4{margin-top: 4px;}
  .timeipt{width: 240px;height: 30px;border: 1px solid #ccc;border-radius: 3px;background: url(images/datePicker.gif) 220px center no-repeat;margin-right: 10px;vertical-align: top;}
  .timeipt2{width: 150px;height: 30px;border: 1px solid #ccc;border-radius: 3px;margin-right: 10px;vertical-align: top;}
  .timelab{font-size: 14px;color: #666;line-height: 30px;font-family: '微软雅黑';margin-right: 10px;}
</style>
<?php require("topbut.php") ?>
<div class="panel panel-inverse">
    <div class="panel-heading">
        <h4 class="panel-title" id="g">订单查询</h4>
    </div>
    <div class="panel-body">

      <form name="form2" method="post" action="home.php?lsact=orderlist&action=query" class="form-horizontal">
        <div class="row">
          <div class="col-md-12">
            <label class="timelab">起</label>
            <input name="time1" type="text" id="time1" size="10" onFocus="new WdatePicker(this,null,false,'whyGreen')" class="timeipt">
            <label class="timelab">止</label>
            <input name="time2" type="text" id="time2" size="10" onFocus="new WdatePicker(this,null,false,'whyGreen')" class="timeipt">
            <!-- <label class="timelab">订单编号</label>
            <input name="orderid" type="text" id="orderid" class="timeipt2"> -->
            <INPUT class="btn btn-sm btn-success"  type="submit"  id="but" value="查询" name="but" style="vertical-align: top;">
          </div>
        </div>
      </form>

      <legend style="margin-top: 20px;">订单列表</legend>

      <div class="table-responsive">
        <table class="table table-striped givetable">
            <tr>
              <th>报单编号</th>
              <th>产品名称</th>
              <th>价格</th>
              <th>数量</th>
              <th>实际支付</th>
              <th>属性</th>
              <th>状态</th>
              <th>确认购物时间</th>
              <th>操作</th>
            </tr>
            <?php
            $action=$_GET['action'];
            $filter='';
            if($action=="query"){

              // $orderid=checkstr($_POST['orderid']);
              $time1=checkstr($_POST['time1']);
              $time2=checkstr($_POST['time2']);

              if (trim($time1)!="") $filter.=" and btime>='".strtotime($time1)."'";
              if (trim($time2)!="") $filter.=" and btime<='".(strtotime($time2)+3600*24)."'";
              // if (trim($orderid)!="") $filter.=" and id='$orderid'";
            }
            $pagecount=10;
            $condition=" where 1=1 ";
            $psql="select count(0) from ld_order $condition  $filter and bid=".$_userid." ";
            $db->query($psql,3);
            $pcount=$db->fval;
            $pagecount=$pagecount;   //每页条数
            $astr="&lsact=orderlist";    //Url
            $pagearr=pagelist($pagecount,$pcount,$astr);
            $offset=$pagearr[1];
            $db->query("select * from ld_order where bid=".$_userid."  $filter order by id desc limit $offset,$pagecount");

            $list=$db->rs;
            if($list){
            foreach ($list as $key => $rs) {
              if($rs['status']==1){
                 $status='<font color="red">未发货</font>';
              }elseif($rs['status']==2){
                $status='已发货';
              }else{
                $status='已签收';
              }
             ?>
            <tr>
            <td><?php echo $rs["id"];?></td>
            <td><?php echo $rs["bpdname"]?></td>
            <td><?php echo $rs["bprice"];?></td>
            <td><?php echo $rs["bnum"];?></td>
            <td><?php echo $rs["bprice"]*$rs["bnum"];?></td>
            <td><?php echo $rs['sx'];?></td>
            <td><?php echo $status;?></td>
            <td><?php echo date("Y-m-d H:i:s",$rs["btime"]);?></td>
            <td>
                <a href="home.php?lsact=orderview&id=<?php echo $rs["id"]?>">查看</a>
            </td>
          </tr>
            <?php
            }
            }else{

          }

          ?>
        </table>
        <?php if(($pcount/$pagecount)>1){?>
        <div class="pagediv"><?php echo $pagearr[0]?></div>
        <?php }?>
         <?php if($pcount==0){?>
         <div class="pagediv" style="text-align:center;color:#E47501">--> 暂无数据</div>

         <?php

         }
         ?>
      </div>
    </div>
</div>
